<!DOCTYPE html>
<html>
<head>
    <title>挂号--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
<form id="myForm" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">姓名</td>
        <td><input type="text" id="registerName" name="registerName" value=""/></td>
    </tr>

    <tr>
        <td width="10%" class="tableleft">身份证号</td>
        <td><input type="text" name="idNumber" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">社保号</td>
        <td><input type="text" name="medicalNumber" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">挂号费</td>
        <td><input type="text"  name="regPrice" value=""/>元</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">联系电话</td>
        <td><input type="text" name="phone" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">是否自费</td>
        <td><input type="radio" name="selfPrice" value="" checked/>否&nbsp;&nbsp;&nbsp;<input type="radio" name="selfPrice" value=""/>是</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">性别</td>
        <td><input type="radio" name="sex" value="1" checked/>男&nbsp;&nbsp;&nbsp;<input type="radio" name="sex" value="0"/>女</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">年龄</td>
        <td><input type="text" id="age" name="age" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">职业</td>
        <td><input type="text" name="profession" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">初复诊</td>
        <td><input type="radio" name="lookDoctor" value="0" checked/>初诊<input type="radio" name="lookDoctor" value="1"/>复诊</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">所挂科室</td>
        <td>
            <select id="department" name="department" onchange="getDoctorByDept()"></select>
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">指定医生</td>
        <td><select id="doctorId" name="doctorId"></select></td>
    </tr>
	<tr>
        <td width="10%" class="tableleft">备注</td>
        <td><textarea name="note"></textarea></td>
	</tr>
    <tr>
        <td colspan="2">
			<center>
				<button type="button" class="btn btn-primary" onclick="add()">保存</button> &nbsp;&nbsp;
                <button type="button" class="btn btn-success" onclick="black()">返回列表</button>
			</center>
		</td>
    </tr>
</table>
</form>
<script>

    showDept();

    //显示科室信息
    function showDept() {
        $.ajax({
            type: "GET",
            url: "/dept/findDept",
            dataType: "json",
            success: function (vo) {
                let data = vo.list;
                let str = "<option>未选择</option>";
                for (let i = 0; i < data.length; i++) {
                    str += "<option  value=\" " + data[i].deptId + "\" >" + data[i].deptName + "</option>"
                }
                $("#department").html(str);

            },
        })
    }

    //显示所选科室的医生
    function getDoctorByDept() {
        var department = $("#department option:checked").val();
        $.ajax({
            type: "GET",
            url: "/Doctor/getDoctorByDept?department="+department,
            success: function (list) {
                var str="";
                for(var i=0;i<list.length;i++){
                    str += "<option  value=\" " + list[i].id + "\" >" + list[i].doctorName + "</option>"
                }
                $("#doctorId").html(str);
            },
        })
    }

    function add(){
        //非空校验
        if($("#registerName").val()=="" || $("#regPrice").val()=="" || $("#age").val()==""
            || $("#department").val()=="" || $("#doctorId").val()==""){
            alert("有主要字段为空");
            return false;
        }
        $.ajax({
            url:"/register/addRegister",
            type:"POST",
            data:$("#myForm").serialize(),
            dataType:"json",
            success:function (vo) {
                alert(vo.msg);
                if(vo.code==200){
                    black();
                }
            }
        });
    }

    function black() {
        window.location.href="index.html";
    }
</script>
</body>
</html>